package com.lry.jvm.rtda.heap;

import com.lry.jvm.util.Util;
import lombok.Data;


public class SymRef {

    private RuntimeConstantPool rcp;
    private String className;
    private JClass jClass;

    public JClass resolvedClass(){
        if(null==jClass){
            resolveClassRef();
        }
        return jClass;
    }

    private void resolveClassRef() {
        JClass d = rcp.getJClass();
        JClass c = d.getLoader().loadClass(className);
        if(!c.isAccessibleTo(d)){
            Util.panic("java.lang.IllegalAccessError");
        }
        jClass = c;
    }

    public RuntimeConstantPool getRcp() {
        return rcp;
    }

    public void setRcp(RuntimeConstantPool rcp) {
        this.rcp = rcp;
    }

    public String getClassName() {
        return className;
    }

    public void setClassName(String className) {
        this.className = className;
    }

    public JClass getjClass() {
        return jClass;
    }

    public void setjClass(JClass jClass) {
        this.jClass = jClass;
    }
}
